package com.feihong.txgw.ui.activity.order;

import android.os.Bundle;
import android.support.v4.view.ViewPager;

import com.astuetz.PagerSlidingTabStrip;
import com.feihong.txgw.R;
import com.feihong.txgw.fragmentadapter.OrderPagerAdapter;
import com.feihong.txgw.message.LoginMessage;
import com.feihong.txgw.ui.activity.base.BaseActivity;
import com.feihong.txgw.utils.ToastUtils;

import butterknife.BindView;

/**
 * 订单页
 */
public class MyOrderActivity extends BaseActivity {
    /**
     * 全部
     */
    public static final int ORDER_STATE_ALL = 0;
    /**
     * 代付款
     */
    public static final int ORDER_STATE_PAY = 1;
    /**
     * 待收货
     */
    public static final int ORDER_STATE_TAKE = 3;
    /**
     * 待评价
     */
    public static final int ORDER_STATE_EVALUATE = 4;
    /**
     * 退款
     */
    public static final int ORDER_STATE_REFUND =8;

    @BindView(R.id.tabs) PagerSlidingTabStrip pagerSlidingTabStrip;
    @BindView(R.id.viewPager) ViewPager viewPager;
    private int index;

    @Override
    public void setTheme() {

    }

    @Override
    public int setLayoutID() {
        return R.layout.activity_recharge;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        index = getIntent().getIntExtra("OrderType", 0);
        //设置页面标题
        setPageTitle("我的订单");
        //设置左上角关闭按钮的事件
        setBackButtonFinish();
        pagerSlidingTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                ToastUtils.cannelToast();
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        OrderPagerAdapter orerAdapter = new OrderPagerAdapter(getSupportFragmentManager());
        viewPager.setAdapter(orerAdapter);
        viewPager.setOffscreenPageLimit(orerAdapter.getCount());
        pagerSlidingTabStrip.setDividerColorResource(R.color.trans);
        pagerSlidingTabStrip.setViewPager(viewPager);
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    public void bindData() {
        switch (index) {
            case 0:
                viewPager.setCurrentItem(0);
                break;
            case 1:
                viewPager.setCurrentItem(1);
                break;
            case 2:
                viewPager.setCurrentItem(2);
                break;
            case 3:
                viewPager.setCurrentItem(3);
                break;
            case 4:
                viewPager.setCurrentItem(4);
                break;
            default:
                viewPager.setCurrentItem(0);
                break;
        }
    }

    @Override
    public void onUserLogin(LoginMessage loginMessage) {

    }
}
